
this is my current arduino package, it works, but is buggie. it was only designed for me so i did not comment well. i am interested to see if this method works on other computers. you can just review it, or try to get the package running on your system.


********the adruino control package consists of several files 

(1) modbus config screenshot. to use activate your modbus/serial pluging on the ports and pins front page and reboot.  then transfer these settings. 


(2) Arduino wizard folder. put inside Addons. calling it a wizard is a push. In arduino folder is arduino1.set plus init.m1s. when launching wizard a 1/2 blank screen might load. if so click the REFRESH button up on top of the wizard page.  that will bring up the rest.  the set file takes a while to load. The init/refresh file will be confusing at first. it is the label text for  each of my  64 arduino pins. ,  it is in vb code, and it writes the  userlabels. page is designed so the relays on my system can be tested.


(3) brains folder. various brains load into your brains folder.

(4) arduino file vinny210.pde. unload this into arduino mega

(5) bunch o' pics folder


********modbus config

this is the settings file for modbus. just copy the settings so they match. the register sequence must match the  the sequence i set up for my mega in the vinny210.pde file.it is easy to edit the order if you want.  after you see how it works you can re-write to suit.dont try to figure out why i have things in the order they are,  it was random development guesswork. the package needs a re-write. note that your com port number might be different. 


set the com speed on the modbus.cfg page and in device manager, set the arduino serial port number to match. note you cannot use the arduino development program and mach3 at same time, they fight over the com port.
launch arduino,set the ports , load and upload the 210.pde file and then quit arduino and launch mach3. 

you will know you are good when you  relaunch mach3 and see the led lights blink like crazy on the adruino mega.the  test modbus system works, you can test and get your first response from the arduino with it.


********adruino folder.  place this into addons. then select it from mach3

this test wizard could be confusing as i wrote it for myself only, you do not need the wizard to 'prove' your arduino connection works, use  a voltmeter to confirm output pins triggered from the test modbus dialog, and 'brain view' will show input pin status.

there is a VB button and file called refresh
attached to the refresh button. click it and VB will fill in all the labels.  this is where i try to interface my complex system. many buttons have bad test code  and artifacts, just delete. hold output buttons for 1 sec. perhaps twice. use all of and all on buttons to test


the outputs are set up for my system. I use 24 outputs, which are wired from the adruino to 2 CNC4PC 12 channel relay boards. the boards are designed for pokeys, so the wiring looks unsettled in the photos. The inputs are also from a CNC4PC input board, on my system. i like these boards. very affordable.


********brains folder. these brains should be transfered to your brain folder / auto load folder . not sure if you need to manually activate them, or if autoload does that for you. i suggest you remove all other brains for your first tests.

there is one brain that reads the analog inputs, one for pwm analog out, one for 20 outputs, etc ; there is one brain  that sets leds on my wizard page , it works on some days.



********Vinny210 program.


 this gets uploaded into the arduino mega, and it communicates with the modbus on mach3. the adruino reads its own pin registers, which it puts into the regs[] array. these are then passed to the mach when it comes polling. the mach brains checks these registers and sets mach leds and inputs based on what the readings are (hi or low). in the other direction, the adruino code  checks what mach has sent over. puts that into the registers and then sets its own outputs accordingly. this is all done in a few lines of code, added to a very complex public domain modbus slave app. search for keyword vinny to find my changes  (sorry, to late to change names). 


more notes. 


********the arduino1.set 


i tried to get a good interface going,  my wizard design is to have each of the 60+ mega buttons to have 4 labels, listing each pins  control point , pin assignment on the  adruino , name inside mach 3 , and  status. this would be easy in VB6 or other enviros, but i could not come  up with  a better  system for mach3 because of its crippled screen designer and VB language.

on the page there is a bank of buttons to turn on each output, send data to a pwm output , and other functions, on the top are  global commands. most dont work.


this page is so far from finished it might not work at all for anyone else. in the end i plan to use a page like this to control my 24 relays. it works now, but needs debugging. if i find time, i might upload a debugged version next saturday.




********step by step .. to run this setup with a mega   . many steps overlooked be carefull


download newest arduino package and install it. get the new mega if you can.  get it running , test it with examples. set up the digital input example hardware (switch and wire)  , you will want to repeat the test
later when hooked up to mach3 to confirm system works.i have set up pin 50 as input.
so perhaps wire and test digital input on pin 50 on your system 


set your com ports to proper port and speed in device manager. i backed off from 57600
to 19200 due to errors  , but source of problems is unclear.

drop arduino folder into add-ons folder inside mach3
 perhaps into a autoload folder.


make a new mach3 profile
launch mach3
enable new brains

set all 20 outputs and inputs except estop to port 0 and enable them
activate modbus serial/plugin and restart
type in modbus config data from screenshot
quit and relaunch again just to be sure
select view brain. leave brain view screen in background
use MACH3 'test modbus' from bus config page , 

on the wizard page , use all off and on buttons (on top) to test
dont depend on little numbered output buttons for testing , they are buggie. 

some upper buttons might cause crashing , wanted to remove them but
was concerned to change anything while system was 'working'.
perhaps next week i will transmit a debugged version.

bugs or not, it works !

********next . . 

i will be glad to answer any questions, until someone else gets it working,  i hope others do some good with it,  Somehow i got this package to work, i hope someone who is ' going the same way' can use its parts. i am very interested in open source development for mach3 addon's. 


i could not use plug-ins because they are in 'greek' to me (a typical vb hacker)  and  i cant write them (yet). so i used the  built in mach3 modbus system and brains, plus a public domain 'modbus slave' file for the arduino. i discovered a arduino can really help in learning 'C' so in time i plan to be writing plugins.

i am going to be  tinkering with arduino/ethernet/mach3 next, i just ordered a $10 ethernet 'shield' for my mega. parts for the arduino are so cheap. for instance a 50 AMP GAUGE / CURRENT transducer for $12.00 !. checkout sparkfun web site / sensors ! ! 

then i will be testing  arduino as a mpg/encoder reader. i plan to send a command from mach  to shut down every arduino function except reading the encoder, and see how fast i can read with it.

my other adruino pipe dream is to use arduino as a 'phanthom smoothstepper' because i fried my real smoothstepper (again) ,  and can't afford another one. 

notes. i use the arduino as a stand in for a pokeys, but remember the pokeys is much more 'professional' and has much better safety features and timing. FYI having a programming language available in your i/o device is FANTASTIC. opens up many doors.


thanks to 'poppa bear' for his work explaining the brains system and modbus and other work. When i was at maker faire last month , i realized i should be working with the open source folks , they remind me of young hippies ! they have so much going on with arduino and wireless and robotics and drone flight control, and most of there work can be ported to CNC. 




